function AssignRoleToMember(memberId,member_name){
    document.getElementById("assign_memberId").value = memberId;
 	$("#AssignRole_title").html("为[<span style='color:red;'>"+member_name+"</span>]角色 指派操作");
 	ajaxGetRoles(memberId);
 	showContainer("AssignRoleToMemberDiv","AssignRole_close");
 }
  function hidenAssignRole(){
    $("#RoleListDiv").html("");
 	hidenContainer("AssignRoleToMemberDiv");
 }
 function ajaxGetRoles(memberId){
 	// Ajax GET  Roles 
	/*-------------function begin---------------------------*/	
	$.ajax({
			type: "post",
	    	dataType:"xml",
			"url" : "AjaxGetMemberRolesServlet",
			//提交的数�
			data: {memberId:memberId},
			beforeSend: function(XMLHttpRequest){
				$("#RoleListDiv").html("数据加载中……");
            },
            success: function(data, textStatus){
               loadRoles(data);
		    },
			complete: function(XMLHttpRequest, textStatus){
			},
			error: function(){
				
			}
	})
	/*-------------function end  ---------------------------*/
 }
 
 function loadRoles(xmlData){
 	
	$("#RoleListDiv").html("");
	 var title       = "";
     var roleId      = "";
     var isContains  = "";
     $(xmlData).find("RoleItem").each(function(index, element) {
        title       = $(this).children("title").text();
        roleId      = $(this).children("roleId").text();
        isContains  = $(this).children("isContains").text();
        if(isContains == "yes"){
        	$("#RoleListDiv").append("<div style='float:left;width:180px;'><input type='checkbox' name='assign_roleId' checked='checked' value='"+roleId+"' />"+title+"</div>");
        }else{
        	$("#RoleListDiv").append("<div style='float:left;width:180px;'><input type='checkbox' name='assign_roleId' value='"+roleId+"' />"+title+"</div>");
        }
     });
     $("#RoleListDiv").append("<div style='clear:both' ></div>");
 }
 
 function AssignRolesToMember(){
 	var choose_roleIds = get_assign_roleIds();
 	var memberId       = document.getElementById("assign_memberId").value;
 	//alert(choose_roleIds);
 	// Ajax Submit Assign role to Member 
	/*-------------function begin---------------------------*/	
	$.ajax({
			type: "post",
	    	dataType:"xml",
			"url" : "SubmitAssignRolesToMemberServlet",
			//提交的数�
			data: {memberId:memberId,roleIds:choose_roleIds},
			beforeSend: function(XMLHttpRequest){
            },
            success: function(data, textStatus){
               var result    =  $(data).find("Result").text();
               if(result == "success"){
                 	$("#opNoticeSpan").html("【用户角色指派】操作成功！");
   		 	 		setTimeout(function(){$("#opNoticeSpan").html("")},3000);
               }
               hidenAssignRole();
		    },
			complete: function(XMLHttpRequest, textStatus){
			},
			error: function(){
				
			}
	})
	/*-------------function end  ---------------------------*/
 	
 }
 function get_assign_roleIds(){
 	assign_roleIds = document.getElementsByName("assign_roleId");
 	var choose_Ids="";
 	for(i = 0; i < assign_roleIds.length ; i++){
 		if(assign_roleIds[i].checked){
 			choose_Ids =choose_Ids + assign_roleIds[i].value + ",";
 		}
 	}
 	if(choose_Ids.length >0){
 		choose_Ids = choose_Ids.substr(0,choose_Ids.length-1);
 	}
 	
 	return choose_Ids;
 }